<?php

namespace App\Console\Commands;

use App\Models\Client;
use Carbon\Carbon;
use Illuminate\Console\Command;

class CleanClient extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'CleanClient';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '清理客户';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $days =  env('GO_SEA',7);
        $rs = Client::query()
            ->where('true_client',1)                //客户
            ->whereNotIn('real_finished',[3,1])        //审核成功，审核中
            ->whereIn('employee_status',[8])    //已成交的，
            ->where('last_updated_at','<',Carbon::today()->subDays($days))
            ->update(['in_sea'=>1,'employee_id'=>NULL]);
        dd($rs);
    }
}
